﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DataLibrary
{

    public class Ctbl_website:IData<tbl_website>
    {
        public Ctbl_website(String myconnecString) : base(myconnecString) { }

        protected override int InsertOnSubmit(tbl_website item, int t)
        {
            return connec.ExecuteNonQuery("proWebsite", CommandType.StoredProcedure, new SqlParameter("@flag", t),
                new SqlParameter("@"+tbl_website.c_Id,item.Id),new SqlParameter("@"+tbl_website.c_Website,item.Website),
                new SqlParameter("@"+tbl_website.c_Xpath,item.Xpath));
        }

        public override List<tbl_website> GetAll(tbl_website item)
        {
            throw new NotImplementedException();
        }

        public override tbl_website GetItemById(object id)
        {
            return GetAll().SingleOrDefault(p => p.Id == Convert.ToInt32(id));
        }

        public override tbl_website GetItem(IDataReader dr)
        {
            tbl_website obj = new tbl_website();
            obj.Id = Convert.ToInt32(dr[tbl_website.c_Id]);
            obj.Website = Convert.ToString(dr[tbl_website.c_Website]);
            obj.Xpath= Convert.ToString(dr[tbl_website.c_Xpath]);
            
            return obj;
        }

        public List<tbl_Auto> GetAuto() {
            List<tbl_Auto> list = new List<tbl_Auto>();

            return list;
        }

        public override List<tbl_website> GetAll()
        {
            return GetAll("select * from " + tbl_website.b_tbl_website, CommandType.Text);
        }
    }
}
